package com.sfy.login.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration //说明这是一个配置 类似：<beans>
@EnableSwagger2 //启用Swagger
public class SwaggerConfig {

    /**
     * 构建文档的基本信息
     */
    public ApiInfo createApi(){
        return new ApiInfoBuilder().title("简单登录").
                description("简单登录+工厂模式+策略模式+模版方法模式")
                .contact(new Contact("司飞阳","","SFYWY0315@163.com"))
                .version("1.0.0").build();
    }
    /**
     * 就是ioc创建实例 修饰方法 方法必须返回对象
     */
    @Bean //将方法的返回值 存储到IOC容器中 类似<bean>
    public Docket createDocket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApi())
                .select().apis(RequestHandlerSelectors.
                        basePackage("com.sfy.login.controller")).build();
    }

}
